<?php

use Phalcon\Mvc\Controller;

class ControllerBase extends Controller
{
	
	public $baseUri;
	public $SS_USER_ID;
	public $total_unread;

	protected function initialize()
	{
		$this->baseUri = $this->url->getBaseUri();
		$this->view->setVar('baseUri', $this->baseUri);


		$user_id = $this->session->get('user_id');
		if($user_id){
	/*	$user_online = UserConnectionsTb::listOnline($this->session->get('user_id'));
		$this->view->setVar("online_friends",$user_online); */
		}

		$this->SS_USER_ID = $user_id;
		$this->total_unread = Notification::countUnread($user_id);
		$this->view->setVar('unread', $this->total_unread);

	}


	public function generateToken()
    {
        return md5(rand(9999,1)."-".time());
    }

   
    

    public function registerSession($id,$fname,$mname,$profile_pic)
    {
    	$this->session->set('user_id',$id);
		$this->session->set('fullname',$fname.' '.$mname);
    	$this->session->set('profile_pic',$profile_pic);
    }

    
}
